#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

archs=(rmall)
pkgnames=(mmc-utils)
pkgdesc="A tool for monitoring the eMMC protocol"
url=https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/
pkgver=1.0-1
timestamp=2021-08-12T19:41:07Z
section="devel"
maintainer="Alistair Francis <alistair@alistair23.me>"
license=GPL-2.0-only

image=base:v2.2
source=(
    0001-Makefile-Remove-Werror.patch
)
sha256sums=(
    SKIP
)
_commit=7769a4d7abe339ce273c13a203394a79a11fcff9

prepare() {
    cd "$srcdir"
    mkdir mmc-utils
    cd mmc-utils
    git init
    git fetch --depth=1 "https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git" "$_commit"
    git checkout -f "$_commit"
    patch < "$srcdir"/0001-Makefile-Remove-Werror.patch
}

build() {
    # Use our toolchain
    export AR=arm-linux-gnueabihf-ar
    export CC=arm-linux-gnueabihf-gcc
    export STRIP=arm-linux-gnueabihf-strip

    make -C "$srcdir"/mmc-utils -j4
}

package() {
    DESTDIR="$pkgdir" make -C "$srcdir"/mmc-utils install
}
